﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BO;

namespace ProjectQuaDep.Control.News
{
    public partial class NewsFocus : System.Web.UI.UserControl
    {
        int TOP_FOCUS = 3;
        int IMG_WIDTH = 88;
        int IMG_HEIGHT = 72;
        string listNewsFormat = "<li><a href=\"{0}\"> <img alt=\"{1}\" src=\"{2}\" /></a> <a class=\"title-news\" href=\"{0}\">{1}</a> </li>";
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = BO.News.NewsBO.GetNewsFocusBO(TOP_FOCUS.ToString());
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string newsID = dt.Rows[i][Const.tbNews.id].ToString();
                    string title = Utils.EnCodeString(dt.Rows[i][Const.tbNews.Title].ToString());
                    string href =  dt.Rows[i][Const.tbNews.Url].ToString();
                    string avatar = Utils.CropImage(IMG_WIDTH, IMG_HEIGHT, dt.Rows[i][Const.tbNews.Avatar].ToString());
                    ltListNews.Text += string.Format(listNewsFormat, href, title, avatar);
                }
            }
        }
    }
}